package xcmg.device.web.split;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import xcmg.device.infra.BasicController;
import xcmg.device.service.split.SplitRecordService;
import xcmg.device.service.vo.split.SplitRecordVO;
import yb.ecp.fast.infra.annotation.FastMappingInfo;
import yb.ecp.fast.infra.infra.ActionResult;
import yb.ecp.fast.infra.infra.PageCommonVO;
import yb.ecp.fast.infra.infra.SearchCommonVO;

@RestController
@RequestMapping("/splitRecord")
public class SplitRecordController extends BasicController {

    @Autowired
    private SplitRecordService splitRecordService;

    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @FastMappingInfo(needLogin = true)
    public ActionResult list(@RequestBody SearchCommonVO<SplitRecordVO> condition)throws Exception{
        SplitRecordVO splitRecordVO = condition.getFilters();
        splitRecordVO.setOrgId(getOrgId());
        condition.setFilters(splitRecordVO);
        PageCommonVO pageCommonVO = splitRecordService.list(condition);
        return actionValueResult(pageCommonVO.getPageInfo());
    }

    @RequestMapping(value = "/exportAll",method = RequestMethod.POST)
    @FastMappingInfo(needLogin = true)
    public void exportAll(SplitRecordVO condition)throws Exception {
        condition.setOrgId(getOrgId());
        splitRecordService.exportAll(condition);
    }

}
